﻿@page "/Error/Basic"
@using LiveChartsCore.SkiaSharpView.Blazor
@using LiveChartsCore;
@using LiveChartsCore.Defaults;
@using LiveChartsCore.SkiaSharpView;

<CartesianChart
    Series="@series0">
</CartesianChart>

<CartesianChart
    Series="@series1">
</CartesianChart>

<CartesianChart
    Series="@series2"
    XAxes="@dateTimeAxis">
</CartesianChart>

@code {
    private static ErrorValue[] values1 = new ErrorValue[]
    {
        new(65, 6),
        new(70, 15, 4),
        new(35, 4),
        new(70, 6),
        new(30, 5),
        new(60, 4, 16),
        new(65, 6)
    };
    private static ErrorPoint[] values2 = new ErrorPoint[]
    {
        new(0, 50, 0.2, 8),
        new(1, 45, 0.1, 0.3, 15, 4),
        new(2, 25, 0.3, 4),
        new(3, 30, 0.2, 6),
        new(4, 70, 0.2, 8),
        new(5, 30, 0.4, 4),
        new(6, 50, 0.3, 6)
    };
    private static ErrorDateTimePoint[] values3 = new ErrorDateTimePoint[]
    {
        new(DateTime.Today.AddDays(0), 50, 0.2, 8),
        new(DateTime.Today.AddDays(1), 45, 0.1, 0.3, 15, 4),
        new(DateTime.Today.AddDays(2), 25, 0.3, 4),
        new(DateTime.Today.AddDays(3), 30, 0.2, 6),
        new(DateTime.Today.AddDays(4), 70, 0.2, 8),
        new(DateTime.Today.AddDays(5), 30, 0.4, 4),
        new(DateTime.Today.AddDays(6), 50, 0.3, 6)
    };
    private static string Formatter(DateTime date) => date.ToString("MMMM dd");

    private ISeries[] series0 = new ISeries[]
    {
        new ColumnSeries<ErrorValue>
        {
            Values = values1,
            ShowError = true
        },
        new ColumnSeries<ErrorPoint>
        {
            Values = values2,
            ShowError = true
        }
    };
    private ISeries[] series1 = new ISeries[]
    {
        new LineSeries<ErrorValue>
        {
            Values = values1,
            ShowError = true
        }
    };
    private ISeries[] series2 = new ISeries[]
    {
        new ScatterSeries<ErrorDateTimePoint>
        {
            Values = values3,
            ShowError = true
        }
    };
    private Axis[] dateTimeAxis = new Axis[]
    {
        new DateTimeAxis(TimeSpan.FromDays(1), Formatter)
    };
}
